package com.eda.commous.http;

import com.github.pagehelper.Page;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

@EqualsAndHashCode(callSuper = true)
@Data
public class PageResult<T> extends Result<List<T>> {
    private int page;
    private int limit;
    private long total;


    public static <T> PageResult<T> of(List<T> list) {
        PageResult<T> pageResult = new PageResult<>();
        pageResult.setResult(list);
        pageResult.setPage(((Page) list).getPageNum());
        pageResult.setLimit(((Page) list).getPageSize());
        pageResult.setTotal(((Page) list).getTotal());
        return pageResult;
    }
}
